#include <iostream>
#include <utility>
#include "testing.h"
#include "BigNumber.h"
#include "utils.h"
using namespace std;

struct FloatNumber
{
	FloatNumber(const string& a)
	{
		string s = a;
		string _str = s;
		int _order = 0;
		int _sign = 0;

		if (s[0] == '+')
		{
			s = s.substr(1, s.length() - 1);
		}

		_sign = (s[0] == '-') ? -1 : 1;
		if (_sign == -1)
		{
			s = s.substr(1, s.length() - 1);
		}

		int ePos = s.find('e');
		if (ePos == -1)
		{
			_str = s;
			_order = 0;
		}
		else
		{
			_str = s.substr(0, ePos);
			string order = s.substr(ePos + 1, s.length() - ePos + 1);
			_order = atoi(order.c_str());
		}

		int dotPos = s.find('.');
		if (dotPos == -1)
		{
		}
		else
		{
			_str = _str.substr(0, dotPos) + _str.substr(dotPos + 1, _str.length() - dotPos + 1);
			_order -= _str.length() - dotPos;
		}

		// moving trailing zeroes to order
		string newStr = trimRight(_str, '0');
		_order += _str.length() - newStr.length();
		_str = newStr;

		mantiss = _str;
		order = _order;
		sign = _sign;
	}

	string mantiss;
	int order;
	int sign;
};

int main()
{
	test("trim 010", string("010"), trim("1010", '1'));
	test("trim 1", string("1"), trim("010", '0'));
	test("trim 010", string("010"), trim("   010     ", ' '));
	test("trim 1010", string("1010"), trim("1010", '8'));
	test("trim 1", string("1"), trim("1", '0'));
	test("trim empty", string(""), trim("00", '0'));

	test("trimLeft 1", string("1"), trimLeft("1", '0'));
	test("trimLeft empty", string(""), trimLeft("11", '1'));
	test("trimRight 1", string("1"), trimRight("1", '0'));
	test("trimRight empty", string(""), trimRight("11", '1'));

	test("padLeft", string("010"), padLeft("10", 3, '0'));
	test("padLeft", string("10"), padLeft("10", 2, '0'));
	test("padRight", string("10--"), padRight("10", 4, '-'));
	test("padRight", string("10"), padRight("10", 2, '-'));

	test("compareTo", -1, BigNumber("100").compareTo(BigNumber("200")));
	test("compareTo", -1, BigNumber("000100").compareTo(BigNumber("200")));
	test("compareTo",  0, BigNumber("100").compareTo(BigNumber("100")));
	test("compareTo",  0, BigNumber("000100").compareTo(BigNumber("100")));
	test("compareTo",  1, BigNumber("200").compareTo(BigNumber("100")));
	test("compareTo",  1, BigNumber("000200").compareTo(BigNumber("100")));

	test("<", true, BigNumber("100") < BigNumber("200"));
	test("<", true, BigNumber("000100") < BigNumber("200"));
	test("==",  true, BigNumber("100") == BigNumber("100"));
	test("!=",  true, BigNumber("000100") != BigNumber("200"));
	test(">",  true, BigNumber("200")> BigNumber("100"));
	test(">",  true, BigNumber("000200") > BigNumber("100"));
	test("<=", true, BigNumber("000100") <= BigNumber("200"));
	test(">=",  true, BigNumber("000200") >= BigNumber("100"));

	test("subtract 200 - 100", BigNumber("100"), BigNumber("200").subtract(BigNumber("100")));
	test("subtract 00341 - 119", BigNumber("222"), BigNumber("00341").subtract(BigNumber("119")));
	test("subtract 00141 - 59", BigNumber("82"), BigNumber("00141").subtract(BigNumber("59")));

	test("multiply 114 * 2", BigNumber("228"), BigNumber("114").multiply(2));
	test("multiply 94 * 9", BigNumber("846"), BigNumber("94").multiply(9));
	test("multiply 17 * 2", BigNumber("34"), BigNumber("17") * 2);

	test("divide", BigNumber("14"), BigNumber("140").divide(BigNumber("10")));
	test("divide", BigNumber("2"), BigNumber("222").divide(BigNumber("111")));

	test("578 / 17", BigNumber("34"), BigNumber("578") / BigNumber("17"));
	test("1024 / 16", BigNumber("64"), BigNumber("1024") / BigNumber("16"));

	test("55 / 10", BigNumber("5.5"), BigNumber("55") / BigNumber("10"));
	test("55 / 100", BigNumber("0.55"), BigNumber("55") / BigNumber("100"));
	test("55 / 1000", BigNumber("0.055"), BigNumber("55") / BigNumber("1000"));
	test("55 / 10000", BigNumber("0.0055"), BigNumber("55") / BigNumber("10000"));


	string s1, s2;
	cin >> s1 >> s2;

	// TODO: CHECK INPUT

	FloatNumber n1 = s1;
	FloatNumber n2 = s2;

	int sign = n1.sign * n2.sign;

	BigNumber result = BigNumber(n1.mantiss) / BigNumber(n2.mantiss);
	FloatNumber floatResult = result.toString();

	string mantiss = floatResult.mantiss;
	int order = (n1.order - n2.order + floatResult.order);

	// format nicely
	int lenMantiss = mantiss.length();
	mantiss = "0."+mantiss;
	order += lenMantiss;

	cout << (sign == 1 ? "" : "-");
	cout << mantiss;
	cout << "e" << order << endl;
}